package com.itany.book.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itany.mapper.ExamineMapper;
import com.itany.pojo.Book;
import com.itany.pojo.Examine;
import com.itany.service.ExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Author：侍家宇
 * Date：2019-09-18 下午2:27
 * Description：<描述>
 */
@Service
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRED)
public class ExamineServiceImpl implements ExamineService {
    @Autowired
    ExamineMapper examineMapper;

    @Transactional(readOnly=true)
    public PageInfo<Examine> findExamineAll(Integer page, Integer rows) {
        PageHelper.startPage(page, rows);
        List<Examine> list = examineMapper.findExamineAll();
        PageInfo<Examine> info = new PageInfo<Examine>(list);
        return info;
    }

    /**
     * 添加书籍审核
     * @param book
     */
    public void addbook(Book book) {
        examineMapper.addbook(book);



    }

    /**
     * 同时添加审核
     * @param examine
     */
    public void addExamine(Examine examine) {
        examineMapper.addExamine(examine);
    }

    public Book findBook(int id) {
        Book book=examineMapper.findBook(id);
        return book;
    }
    @Transactional(readOnly=true)
    public PageInfo<Examine> findByCondition(Book book, Integer page, Integer rows) {
        PageHelper.startPage(page,rows);
        List<Examine> list = examineMapper.findByCondition(book);
        PageInfo<Examine> info = new PageInfo<Examine>(list);
        return info;
    }

    public void addBookSupplier(Book book) {
        examineMapper.addBookSupplier(book);
    }

    public void modifyExamine(Examine examine) {
        examineMapper.modifyExamine(examine);

    }
}
